package fr.mehfile.view;

import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TabHost;
import android.widget.TabWidget;
import android.widget.TextView;
import fr.mehfile.R;
import fr.mehfile.timetable.TimeTableModel;

public class TimeTable extends TabActivity implements View.OnClickListener  {
	
	private TabHost tabHost;
	
	@Override
	public void onCreate(Bundle icicle) {
		super.onCreate(icicle);
		setContentView(R.layout.timetable);
		
		this.tabHost = getTabHost();
		//this.tabHost.getTabWidget().setDividerDrawable(R.drawable.tab_divider);
		Intent intentToday = new Intent().setClass(this, TimeTableTab.class);
		intentToday.putExtra("day", "today");
		Intent intentTomorrow = new Intent().setClass(this, TimeTableTab.class);
		intentTomorrow.putExtra("day", "tomorrow");
        setupTab("", "", intentToday);
        setupTab(" ", " ", intentTomorrow);
		
        TabWidget tabWidget = this.tabHost.getTabWidget();
        this.initTabsAppearance(tabWidget);
	}

	public void onClick(View arg0) {
		// TODO Auto-generated method stub
		
		
	}
	
	private void setupTab(String name, String tag, Intent intent) {
		tabHost.addTab(tabHost.newTabSpec(tag).setIndicator(tag).setContent(intent));
	}
	
	private void initTabsAppearance(TabWidget tabWidget) {
	    // Change background
	    tabWidget.getChildAt(0).setBackgroundResource(R.drawable.tab_bg_selector_today);
	    tabWidget.getChildAt(0).getLayoutParams().width = LayoutParams.FILL_PARENT;
	    float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 45, getResources().getDisplayMetrics());
	    tabWidget.getChildAt(0).getLayoutParams().height = (int)px;
	    tabWidget.getChildAt(1).setBackgroundResource(R.drawable.tab_bg_selector_tomorrow);
	    tabWidget.getChildAt(1).getLayoutParams().width =LayoutParams.FILL_PARENT;
	    tabWidget.getChildAt(1).getLayoutParams().height = (int)px;
	    tabWidget.getChildAt(0).setSelected(true);
	}
	

}
